package com.fc.v2.service;

import java.util.List;
import java.util.Arrays;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import cn.hutool.core.util.StrUtil;
import com.fc.v2.common.base.BaseService;
import com.fc.v2.common.support.ConvertUtil;
import com.fc.v2.mapper.auto.ApplyFinishMapper;
import com.fc.v2.model.auto.ApplyFinish;
import com.fc.v2.model.auto.ApplyFinishExample;
import com.fc.v2.model.custom.Tablepar;
import com.fc.v2.util.SnowflakeIdWorker;
import com.fc.v2.util.StringUtils;

/**
 * 立项与结项Id映射 ApplyFinishService
 * @Title: ApplyFinishService.java 
 * @Package com.fc.v2.service 
 * @author Archie_自动生成
 * @email ${email}
 * @date 2021-12-13 14:47:05  
 **/
@Service
public class ApplyFinishService implements BaseService<ApplyFinish, ApplyFinishExample>{
	@Autowired
	private ApplyFinishMapper applyFinishMapper;
	
      	   	      	      	      	
	/**
	 * 分页查询
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	 public PageInfo<ApplyFinish> list(Tablepar tablepar,ApplyFinish applyFinish){
	        ApplyFinishExample testExample=new ApplyFinishExample();
			//搜索
			if(StrUtil.isNotEmpty(tablepar.getSearchText())) {//小窗体
	        	testExample.createCriteria().andLikeQuery2(tablepar.getSearchText());
	        }else {//大搜索
	        	testExample.createCriteria().andLikeQuery(applyFinish);
	        }
			//表格排序
			//if(StrUtil.isNotEmpty(tablepar.getOrderByColumn())) {
	        //	testExample.setOrderByClause(StringUtils.toUnderScoreCase(tablepar.getOrderByColumn()) +" "+tablepar.getIsAsc());
	        //}else{
	        //	testExample.setOrderByClause("id ASC");
	        //}
	        PageHelper.startPage(tablepar.getPage(), tablepar.getLimit());
	        List<ApplyFinish> list= applyFinishMapper.selectByExample(testExample);
	        PageInfo<ApplyFinish> pageInfo = new PageInfo<ApplyFinish>(list);
	        return  pageInfo;
	 }

	@Override
	public int deleteByPrimaryKey(String ids) {
				
			List<String> lista=ConvertUtil.toListStrArray(ids);
			ApplyFinishExample example=new ApplyFinishExample();
			example.createCriteria().andIdIn(lista);
			return applyFinishMapper.deleteByExample(example);
			
				
	}
	
	
	@Override
	public ApplyFinish selectByPrimaryKey(String id) {
				
			return applyFinishMapper.selectByPrimaryKey(id);
				
	}

	
	@Override
	public int updateByPrimaryKeySelective(ApplyFinish record) {
		return applyFinishMapper.updateByPrimaryKeySelective(record);
	}
	
	
	/**
	 * 添加
	 */
	@Override
	public int insertSelective(ApplyFinish record) {
				
		//添加雪花主键id
		record.setId(SnowflakeIdWorker.getUUID());
			
				
		return applyFinishMapper.insertSelective(record);
	}
	
	
	@Override
	public int updateByExampleSelective(ApplyFinish record, ApplyFinishExample example) {
		
		return applyFinishMapper.updateByExampleSelective(record, example);
	}

	
	@Override
	public int updateByExample(ApplyFinish record, ApplyFinishExample example) {
		
		return applyFinishMapper.updateByExample(record, example);
	}

	@Override
	public List<ApplyFinish> selectByExample(ApplyFinishExample example) {
		
		return applyFinishMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(ApplyFinishExample example) {
		
		return applyFinishMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(ApplyFinishExample example) {
		
		return applyFinishMapper.deleteByExample(example);
	}
	
	/**
	 * 修改权限状态展示或者不展示
	 * @param applyFinish
	 * @return
	 */
	public int updateVisible(ApplyFinish applyFinish) {
		return applyFinishMapper.updateByPrimaryKeySelective(applyFinish);
	}


}
